
/* 

Paper: Gentrification and pioneer businesses 
Authors: Behrens, Boulam, Martin, Mayneris 

Name dofile: identify_pioneers_negbin_alt.do  
Version: 11 nov. 2021 

Output: dataset pioneers_final_negbin_alt.dta with the list of pioneer sectors  if we do not account for the probability to locate in poor neighborhoods

Inputs:

 - pioneer_gentri90_only`n'_negbin_`v'_1990 with n in {pc, sh_edu, gentri} and v in {250, 500, cont} [produced in compute_elasticity_negbin.do] [publicly available]

*/ 


foreach n in "250" "500" "cont"{
	foreach v in "pc" "sh_edu"{
	use "pioneer_gentri90_only`n'_negbin_`v'_1990.dta",clear

	// we generate dummies for significance of coefficients
	g siginit`n'=abs(coef_`v'_gr_poor_init`n'/se_`v'_gr_poor_init`n')>2.576&coef_`v'_gr_poor_init`n'!=.
		
	// we create dummies for pioneers 
	gen pioneer_`n'_`v'_high= (coef_`v'_gr_poor_init`n'>0&siginit`n'==1)
	saveold pioneers`n'_negbin_`v'3.dta, replace  
		}
	}
	
foreach n in "250" "500" "cont"{
	foreach v in "gentri"{
	use pioneer_gentri90_only`n'_negbin_`v'_1990.dta,clear
	
	// we generate dummies for significance of coefficients
	g siginit`n'=abs(coef_`v'_init`n'/se_`v'_init`n')>2.576&coef_`v'_init`n'!=.
		
	// we create dummies for pioneers 
	gen pioneer_`n'_`v'_high= (coef_`v'_init`n'>0&siginit`n'==1)
	saveold pioneers`n'_negbin_`v'3.dta, replace  
		}
	}

	// we define as pioneer sectors that appear as such for at least 2 out of the 3 estimations
	use pioneers250_negbin_gentri3.dta, clear
	merge 1:1 naics using pioneers500_negbin_gentri3.dta
	drop _m
	merge 1:1 naics using pioneerscont_negbin_gentri3.dta
	drop _m
	foreach n in "250" "500" "cont"{
		foreach v in "pc" "sh_edu"{
		merge 1:1 naics using pioneers`n'_negbin_`v'3.dta
		drop _m
		}
	}
		
	gen var_pioneer_high_alt=pioneer_250_pc_high+pioneer_500_pc_high+pioneer_cont_pc_high+pioneer_250_sh_edu_high+pioneer_500_sh_edu_high+pioneer_cont_sh_edu_high+pioneer_250_gentri_high+pioneer_500_gentri_high+pioneer_cont_gentri_high
	gen pioneer_high_negbin_alt= (var_pioneer_high_alt>5&var_pioneer_high_alt!=.)
	label var pioneer_high_negbin_alt "Dummy is 1 if the sector is pioneers (alternative def.)"
	keep naics* pioneer_high_negbin_alt
	save "pioneers_final_negbin_alt.dta", replace
	
	